# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html

import scrapy

from components.custom_item import UpdateCustomItem
from utils.tools import *


class NetJobCompanyDetailBaseItem(UpdateCustomItem):
    __update_key__ = [
        "company_id",
        "source",
        "short_name",
        "financing_now",
        "scale",
        "company_desc",
        "industry",
    ]
    __table_name__ = 'net_job_company_detail'

    company_id = scrapy.Field()  # 企业id(对应来源内部id)
    source = scrapy.Field()  # 来源
    short_name = scrapy.Field()  # 企业简称
    company_desc = scrapy.Field()  # 企业简介
    financing_now = scrapy.Field()  # 企业融资阶段
    scale = scrapy.Field()  # 企业规模
    industry = scrapy.Field()  # 企业行业类型


class NetJobCompanyDetailItem(UpdateCustomItem):
    __update_key__ = [
        "company_id",
        "source",
        "company_name",
        "short_name",
        "financing_now",
        "scale",
        "industry",
        "nature",
        "job_num",
        "boss_num",
        "company_desc",
        "group_name",
        "phone",
        "email",
        "web_url",
        "work_time",
        "work_time_extend",
        "work_benefit_tags",
        "culture",
        "develop",
        "talents",
        "talent_train",
        "address_list",
        "manager_list",
        "financing_info",
        "credit_label",
        "products",
        "url",
    ]
    __table_name__ = 'net_job_company_detail'

    company_id = scrapy.Field()  # 企业id(对应来源内部id)
    source = scrapy.Field()  # 来源
    company_name = scrapy.Field()  # 企业名称
    short_name = scrapy.Field()  # 企业简称
    financing_now = scrapy.Field()  # 企业融资阶段
    scale = scrapy.Field()  # 企业规模
    industry = scrapy.Field()  # 企业行业类型
    nature = scrapy.Field()  # 企业性质
    job_num = scrapy.Field()  # 企业在招职位数量
    boss_num = scrapy.Field()  # 企业招聘者数量
    company_desc = scrapy.Field()  # 企业简介
    group_name = scrapy.Field()  # 企业所属集团
    phone = scrapy.Field()  # 企业电话
    email = scrapy.Field()  # 企业邮箱
    web_url = scrapy.Field()  # 企业官网
    work_time = scrapy.Field()  # 企业工作时间
    work_time_extend = scrapy.Field()  # 工作时间类型（补充/标签）
    work_benefit_tags = scrapy.Field()  # 企业标签（含福利标签）+说明
    culture = scrapy.Field()  # 企业文化
    develop = scrapy.Field()  # 企业发展历程
    talents = scrapy.Field()  # 企业人才发展标签列表
    talent_train = scrapy.Field()  # 人才发展说明
    address_list = scrapy.Field()  # 企业地址
    manager_list = scrapy.Field()  # 企业高管信息
    financing_info = scrapy.Field()  # 企业融资情况
    credit_label = scrapy.Field()  # 企业增信标签
    products = scrapy.Field()  # 企业产品
    url = scrapy.Field()  # 企业主页url


class NetJobDetailItem(UpdateCustomItem):
    __update_key__ = [
        "company_id",
        "source",
        "job_id",
        "name",
        "degree",
        "experience",
        "job_address",
        "salary",
        "evaluation_tags",
        "keywords",
        "hr_name",
        "hr_position",
        "state",
    ]
    __table_name__ = 'net_job_detail'

    company_id = scrapy.Field()  # 企业id(对应来源内部id)
    source = scrapy.Field()  # 来源
    job_id = scrapy.Field()  # 职位id(对应来源内部id)
    name = scrapy.Field()  # 岗位名称
    degree = scrapy.Field()  # 学历要求
    experience = scrapy.Field()  # 经验要求
    job_area = scrapy.Field()  # 岗位地区
    job_address = scrapy.Field()  # 岗位地址
    salary = scrapy.Field()  # 薪资范围
    functional_type = scrapy.Field()  # 职能类别
    publish_time = scrapy.Field()  # 发布时间
    job_desc = scrapy.Field()  # 岗位描述
    salary_detail = scrapy.Field()  # 薪资详情
    other_info = scrapy.Field()  # 其他信息
    evaluation_tags = scrapy.Field()  # 岗位福利标签
    keywords = scrapy.Field()  # 岗位搜索标签
    recruitment_status = scrapy.Field()  # 招聘状态
    hr_name = scrapy.Field()  # 招聘者称呼
    hr_position = scrapy.Field()  # 招聘者岗位/描述
    hr_tags = scrapy.Field()  # 招聘者标签
    url = scrapy.Field()  # 详情url

    state = scrapy.Field()  # 数据状态

    def pre_to_db(self):
        self.state = 1


class NetJobEnterpriseBusinessInfoItem(UpdateCustomItem):
    __update_key__ = [
        "company_id",
        "source",
        "taxpayer_id",
        "start_time",
        "regist_capi",
        "oper_name",
        "address",
        "industry",
        "city",
        "province",
        "record_authority",
        "operating_dur",
        "corp_type",
        "operating_status",
        "operating_scope",
    ]
    __table_name__ = 'net_job_enterprise_business_info'

    company_id = scrapy.Field()  # 企业id(对应来源内部id)
    source = scrapy.Field()  # 来源
    taxpayer_id = scrapy.Field()  # 统一信用代码
    start_time = scrapy.Field()  # 成立时间
    regist_capi = scrapy.Field()  # 注册资本
    oper_name = scrapy.Field()  # 法人代表
    address = scrapy.Field()  # 注册地址
    industry = scrapy.Field()  # 所属行业
    city = scrapy.Field()  # 城市
    province = scrapy.Field()  # 省份
    record_authority = scrapy.Field()  # 登记机关
    operating_dur = scrapy.Field()  # 营业期限
    corp_type = scrapy.Field()  # 企业类型
    operating_status = scrapy.Field()  # 经营状态
    operating_scope = scrapy.Field()  # 经营范围


class NetJobTasteItem(UpdateCustomItem):
    __update_key__ = [
        "company_id",
        "source",
        "taste_id",
        "name",
        "position",
        "work_year",
        "evaluation_tags",
        "evaluation_content",
        "like_count",
        "see_count",
    ]
    __table_name__ = 'net_job_taste'

    company_id = scrapy.Field()  # 企业id(对应来源内部id)
    source = scrapy.Field()  # 来源
    taste_id = scrapy.Field()  # 评论id
    name = scrapy.Field()  # 企业职员称呼
    position = scrapy.Field()  # 职位/头衔
    work_year = scrapy.Field()  # 工作年限
    evaluation_tags = scrapy.Field()  # 评价标签
    evaluation_content = scrapy.Field()  # 评价文案
    like_count = scrapy.Field()  # 评价的点赞数
    see_count = scrapy.Field()  # 评价的阅读数
